<template>
  <div>
    <video :style="{
        width: `${this.width}px`,
        height: `${this.height}px`,
        backgroundColor: 'black',
        borderRadius: '5px',
        border: '1px solid'
      }" :src="addUrl" @click="player($event)">
      <source :src="addUrl" type="video/mp4">
    </video>
  </div>
</template>

<script>
  export default {
    name: "VideoPreview",
    props: {
      src: {},
      width: {
        type: String,
        default: "100"
      },
      height: {
        type: String,
        default: "100"
      },
    },
    data() {
      return {}
    },
    created() {},
    methods: {
      player(event) {
        event.target.play()
      }
    },
    computed: {
      addUrl() {
        if (!this.src) {
          return "";
        }
        if(this.src.indexOf('http')!=-1){
        return this.src;
        }
        return this.$resVideoBaseUrl + this.src
      }
    },

  };
</script>

<style lang="scss" scoped>
  .el-image {
    border-radius: 5px;
    background-color: #ebeef5;
    box-shadow: 0 0 5px 1px #ccc;

    ::v-deep .el-image__inner {
      transition: all 0.3s;
      cursor: pointer;

      &:hover {
        transform: scale(1.2);
      }
    }

    ::v-deep .image-slot {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 100%;
      color: #909399;
      font-size: 30px;
    }
  }
</style>
